<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>

    <template id="my-app">
        <component-a></component-a>
        <component-b></component-b>
    </template>

    <template id="component-a">
        <h2>{{title}}</h2>
        <h4>{{content}}</h4>
    </template>
    <template id="component-b">
        <h2>{{title}}</h2>
        <h4>{{content}}</h4>
    </template>
    <script src="../../js/vue.js"></script>
    <script>
        const App = {
            template: '#my-app'
        };
        const app = Vue.createApp(App);
        // 注册全局组件使用app.component()
        app.component('component-a',{
            template: '#component-a',
            data(){
                return {
                    title: '我是标题',
                    content: '我是内容'
                }
            }
        });
        app.component('component-b',{
            template: '#component-b',
            data(){
                return {
                    title: '我是副标题',
                    content: '我是内容'
                }
            }
        })
        app.mount('#app');
    </script>
</body>
</html>